import requestProxy from '@/utils/request';

const { request } = requestProxy;

// 客户列表
export function getList(params) {
  return request({
    url: '/admin/client/list',
    method: 'get',
    params
  });
}
// 新增客户
export function addClient(data) {
  return request({
    url: '/admin/client/create',
    method: 'post',
    data
  });
}

// 删除客户
export function delClient(id) {
  return request({
    url: `admin/client/${id}/customer`,
    method: 'delete'
  });
}

// 编辑客户
export function editClient(id, data) {
  return request({
    url: `/admin/client/${id}/edit`,
    method: 'put',
    data
  });
}

// 客户-一般纳税人证明下载记录日志
export function clientAttachmentDownload(data) {
  return request({
    url: 'admin/client/attachment/download',
    method: 'post',
    data
  });
}

// 编辑客户付款人
export function editClientPayer(id, status) {
  return request({
    url: `admin/client/payer/${id}?status=${status}`,
    method: 'put'
  });
}

// 客户名称唯一性
export function onlyClient(clientName) {
  return request({
    url: '/admin/client/onlyName',
    method: 'get',
    params: {
      clientName
    }
  });
}

// 客户列表导入
export function importClient(fileData) {
  return request({
    url: '/admin/client/import',
    method: 'post',
    data: {
      fileData
    }
  });
}

// 客户列表导出
export function exportClient(params) {
  return request({
    url: '/admin/resource/export',
    method: 'get',
    params: {
      clientType: params.clientType,
      clientName: params.clientName,
      contactPerson: params.contactPerson,
      createName: params.createName,
      createStart: params.createStart,
      createEnd: params.createEnd
    }
  });
}

// 获取客户信息
export function getClientInfo(id) {
  return request({
    url: `/admin/client/info/${id}`,
    method: 'get'
  });
}

// 查看客户联系方式
export function checkClientPhone(id) {
  return request({
    url: `admin/client/phone/check/${id}`,
    method: 'get'
  });
}

// 操作日志
export function clientLogs(id) {
  return request({
    url: `admin/client/logs/${id}`,
    method: 'get'
  });
}

// 供应商操作日志备注修改
export function clientLogRemarkEdit(data) {
  return request({
    url: 'admin/client/logs/edit',
    method: 'put',
    data
  });
}
// // 获取客户信息
// export function getClientDetail(params) {
//   return request({
//     url: '/admin/client/detail/${params.id}',
//     method: 'get',
//     params
//   });
// }
// 获取客户联系人
export function getClientContacts(id, params) {
  return request({
    url: `admin/client/${id}/contact`,
    method: 'get',
    params
  });
}
// 获取客户付款人
export function getClientPayers(id, params) {
  return request({
    url: `admin/client/${id}/payer`,
    method: 'get',
    params
  });
}
export function getClientDashboard(params) {
  return request({
    url: '/admin/client/dashboard',
    method: 'get',
    params
  });
}

export function getClientDetailDashboard(params) {
  return request({
    url: '/admin/client/order/list/dashboard',
    method: 'get',
    params
  });
}
export function getClientOrderList(params) {
  return request({
    url: '/admin/client/order/list',
    method: 'get',
    params
  });
}

export function createSettlement(data) {
  return request({
    url: '/admin/client/create/settlement',
    method: 'post',
    data
  });
}

export function settlementDetail(params) {
  return request({
    url: `/admin/client/settlement/detail/${params.id}`,
    method: 'get',
    params
  });
}

export function editSettlement(data) {
  return request({
    url: '/admin/client/edit/settlement',
    method: 'put',
    data
  });
}

export function settlementLog(params) {
  return request({
    url: '/admin/client/settlement/log',
    method: 'get',
    params
  });
}

export function examineSettlement(data) {
  return request({
    url: '/admin/client/settlement/examine',
    method: 'post',
    data
  });
}
export function closeSettlement(data) {
  return request({
    url: '/admin/client/settlement/close',
    method: 'post',
    data
  });
}

export function settlementList(params) {
  return request({
    url: '/admin/client/settlement/list',
    method: 'get',
    params
  });
}

export function settlementTabs(params) {
  return request({
    url: '/admin/client/settlement/tab',
    method: 'get',
    params
  });
}

// 删除客户结算单
export function settlementDel(id) {
  return request({
    url: `admin/client/settlement/delete/${id}`,
    method: 'delete'
  });
}

export function deleteFile(data) {
  return request({
    url: '/admin/client/settlement/file/delete',
    method: 'delete',
    data
  });
}
// 调整账期
export function setAccountPeriod(data) {
  return request({
    url: 'admin/client/edit/accountPeriod',
    method: 'put',
    data
  });
}
// 调整等级
export function editClientLevel(data) {
  return request({
    url: 'admin/client/level/edit',
    method: 'put',
    data
  });
}
// 调整状态
export function editClientStatus(data) {
  return request({
    url: 'admin/client/status/edit',
    method: 'put',
    data
  });
}
// 调整额度
export function editClientOweAmount(data) {
  return request({
    url: 'admin/client/oweAmount/edit',
    method: 'put',
    data
  });
}

// 提交封存
export function submitSeal(data) {
  return request({
    url: 'admin/client/settlement/submitSeal',
    method: 'post',
    data
  });
}
// 撤回
export function settlementBack(data) {
  return request({
    url: 'admin/client/settlement/back',
    method: 'post',
    data
  });
}
// 批量更新客户销售
export function batchUpdate(data) {
  return request({
    url: 'admin/client/batchUpdate',
    method: 'post',
    data
  });
}
// 批量更新客户销售
export function batchUpdateDepartment(data) {
  return request({
    url: 'admin/client/updateDepartment',
    method: 'post',
    data
  });
}
// 获取更新客户销售状态
export function getUpdateStatus(data) {
  return request({
    url: 'admin/client/updateStatus',
    method: 'post',
    data
  });
}
// 批量删除客户联系人
export function batchDelete(data) {
  return request({
    url: 'admin/customer/contact/batchDelete',
    method: 'delete',
    data
  });
}
// 删除客户联系人
export function deleteContact(id) {
  return request({
    url: `admin/customer/contact/delete/${id}`,
    method: 'delete'
  });
}
export function getReturnReportList(params, cancelToken) {
  return request({
    url: 'admin/return/list',
    method: 'get',
    params,
    cancelToken
  });
}
// 批量设置协作人
export function setAssociate(data) {
  return request({
    url: 'admin/customer/contact/setAssociate',
    method: 'put',
    data
  });
}
// 批量设置协作部门
export function setCooDepartment(data) {
  return request({
    url: 'admin/customer/contact/setCooDepartment',
    method: 'put',
    data
  });
}
export function getReturnSaleList(params) {
  return request({
    url: 'admin/return/detail/sale/list',
    method: 'get',
    params
  });
}

// 生成报表
export function createReturnReport(data) {
  return request({
    url: 'admin/return/create',
    method: 'post',
    data
  });
}

//  重设报表
export function resetReturnReport(data) {
  return request({
    url: 'admin/return/reset',
    method: 'post',
    data
  });
}

// 回款报表详情-统计数据
export function getReturnStatistics(id, params) {
  return request({
    url: `admin/return/detail/statistics/${id}`,
    method: 'get',
    params
  });
}

// 回款报表详情-列表
export function getReturnDetailList(id, params) {
  return request({
    url: `admin/return/detail/list/${id}`,
    method: 'get',
    params
  });
}

// 回款列表详情-动态表头
export function getDynamicTitle(id, params) {
  return request({
    url: `admin/return/detail/dynamicTitle/${id}`,
    method: 'get',
    params
  });
}

export function deleteReturnList(data) {
  return request({
    url: `admin/return/delete/${data.id}`,
    method: 'delete',
    data
  });
}

export function getContactList(params) {
  return request({
    url: 'admin/customer/contact/list',
    method: 'get',
    params
  });
}

export function editContact(id, data) {
  return request({
    url: `admin/customer/contact/edit/${id}`,
    method: 'put',
    data
  });
}
export function addFile(data) {
  return request({
    url: 'admin/client/settlement/file/add',
    method: 'post',
    data
  });
}

export function getClientGroup(params) {
  return request({
    url: '/admin/client/group/list',
    method: 'get',
    params
  });
}

// 客户调额申请列表
export function getClientAdjustmentList(params, cancelToken) {
  return request({
    url: 'admin/customerAdjustment/list',
    method: 'get',
    params,
    cancelToken
  });
}

// 客户调额申请列表tab
export function getClientAdjustmentTabs(params) {
  return request({
    url: 'admin/customerAdjustment/tab',
    method: 'get',
    params
  });
}

// 客户调额申请发起
export function clientAdjustmentCreate(data) {
  return request({
    url: 'admin/customerAdjustment/create',
    method: 'post',
    data
  });
}

// 客户调额申请发起表单
export function clientAdjustmentformSubmit(data) {
  return request({
    url: 'admin/customerAdjustment/formSubmit',
    method: 'post',
    data
  });
}

// 客户调额申请详情
export function clientAdjustmentDetail(id) {
  return request({
    url: `admin/customerAdjustment/detail/${id}`,
    method: 'get'
  });
}

// 客户调额申请删除
export function delClientAdjustment(id) {
  return request({
    url: `admin/customerAdjustment/delete/${id}`,
    method: 'delete'
  });
}

// 获取客户等级对应名称&岗位
export function getLevelList(params) {
  return request({
    url: 'admin/client/levelList',
    method: 'get',
    params
  });
}

// 客户调额申请编辑
export function editClientAdjustment(data) {
  return request({
    url: `admin/customerAdjustment/edit/${data.id}`,
    method: 'put',
    data
  });
}

// 评论列表
export function getCustomerAdjustmentComments(params) {
  return request({
    url: 'admin/customerAdjustment/comments/list',
    method: 'get',
    params
  });
}

// 发表评论
export function customerAdjustmentCommentAdd(data) {
  return request({
    url: '/admin/customerAdjustment/comments/add',
    method: 'post',
    data
  });
}

// 流程 - 撤销
export function customerAdjustmentProcessRevocation(data) {
  return request({
    url: '/admin/customerAdjustment/process/revocation',
    method: 'post',
    data
  });
}

// 流程 - 撤回
export function customerAdjustmentProcessRecall(data) {
  return request({
    url: '/admin/customerAdjustment/process/recall',
    method: 'post',
    data
  });
}

// 流程审批
export function customerAdjustmentProcessAudit(data) {
  return request({
    url: '/admin/customerAdjustment/process/audit',
    method: 'post',
    data
  });
}

// 获取调整后客户内容
export function queryAdjustedContent(data) {
  return request({
    url: 'admin/customerAdjustment/adjustedContent',
    method: 'post',
    data
  });
}

// 客户账单列表
export function getCustomerBillList(params) {
  return request({
    url: 'admin/customerBill/list',
    method: 'get',
    params
  });
}

// 客户账单统计数据
export function customerBillStatistics(params) {
  return request({
    url: 'admin/customerBill/statistics',
    method: 'get',
    params
  });
}

// 客户账单 - 添加账单
export function addCustomerBill(data) {
  return request({
    url: 'admin/customerBill/add',
    method: 'post',
    data
  });
}

// 客户账单 - 更新
export function updateCustomerBill(id) {
  return request({
    url: `admin/customerBill/update/${id}`,
    method: 'put'
  });
}

// 客户账单 - 详情
export function customerBillDetail(id) {
  return request({
    url: `admin/customerBill/detail/${id}`,
    method: 'get'
  });
}

// 客户账单 - 详情统计数据
export function customerBillDetailStatistics(params) {
  return request({
    url: 'admin/customerBill/detail/statistics',
    method: 'get',
    params
  });
}

// 客户账单 - 导出
export function customerBillExport(params) {
  return request({
    url: 'admin/customerBill/export',
    method: 'get',
    params
  });
}

export function getCustomerCooperation(params, cancelToken) {
  return request({
    url: 'admin/client/cooperation',
    method: 'get',
    params,
    cancelToken
  });
}
export function getCustomerCooperationTab(params) {
  return request({
    url: 'admin/client/cooperation/tab',
    method: 'get',
    params
  });
}
export function delClientCooperation(id) {
  return request({
    url: `/admin/client/cooperation/delete/${id}`,
    method: 'delete'
  });
}
export function getApproverList(data) {
  return request({
    url: `/admin/client/approver`,
    method: 'post',
    data
  });
}
export function cooperationCreate(data) {
  return request({
    url: '/admin/client/cooperation/create',
    method: 'post',
    data
  });
}
export function cooperationApprover(data) {
  return request({
    url: '/admin/client/cooperation/approve',
    method: 'post',
    data
  });
}

export function addClientRemark(data) {
  return request({
    url: '/admin/client/remark/add',
    method: 'post',
    data
  });
}

export function getClientRemarkList(params) {
  return request({
    url: '/admin/client/remark/list',
    method: 'get',
    params
  });
}

export function repeatClientName(data) {
  return request({
    url: '/admin/client/cooperation/repeat',
    method: 'post',
    data
  });
}

// 编辑客户联系人状态
export function editContactStatus(id, status) {
  return request({
    url: `admin/customer/contact/${id}?status=${status}`,
    method: 'put'
  });
}

// 删除客户付款人
export function deletePayer(id) {
  return request({
    url: `admin/client/payer/delete/${id}`,
    method: 'delete'
  });
}

// 新增客户联系人
export function addClientContact(id, data) {
  return request({
    url: `admin/customer/contact/add/${id}`,
    method: 'post',
    data
  });
}

// 新增客户付款人
export function addClientPayer(id, data) {
  return request({
    url: `admin/client/payer/add/${id}`,
    method: 'post',
    data
  });
}

// 编辑客户付款人
export function editPayer(id, data) {
  return request({
    url: `admin/client/payer/edit/${id}`,
    method: 'put',
    data
  });
}
